/*
 * Copyright Hundsun Technologies Inc. All Rights Reserved.
 */

package types

const (
	//WorkerModule worker
	WorkerModule = "worker"
	//P2pModule p2p
	P2pModule = "p2p"
	//ConsensusModule consensus
	ConsensusModule = "consensus"
	//RPCModule rpc
	RPCModule = "rpc"
	//BlockChainModule blockchain
	BlockChainModule = "blockchain"
	//SequenceCenterModule sequence center
	SequenceCenterModule = "sequencecenter"
	//ParachainModule para chain
	ParachainModule = "parachain"
)

//log type
const (
	TyLogUnknown  = 0
	TyLogErr      = 1
	TyLogFee      = 2
	TyLogTransfer = 3
	TyLogGenerate = 4
	TyLogFrozen   = 5
	TyLogRollback = 6
)

//GetEventName  获取时间name通过事件id
func GetEventName(event int) string {
	if name, ok := eventName[event]; ok {
		return name
	}
	return "unknown-event"
}

const (
	//System 系统事件前缀, 所有的系统合约执行器都需要加sys前缀
	System = "sys"
	//SystemSeparator 分隔符
	SystemSeparator = "."
	//SystemParam 配置
	SystemParam = System + SystemSeparator + "param"
	//SystemConsensus 共识
	SystemConsensus = System + SystemSeparator + "consensus"
	//SystemCert 证书
	SystemCert = System + SystemSeparator + "cert"
	//SystemNode 节点
	SystemNode = System + SystemSeparator + "node"
)

// GenSysContractName generate system contract name
func GenSysContractName(contract string) string {
	return System + SystemSeparator + contract
}

// GeneSysParamUpdateKeyPrefix generate system parameter prefix
func GeneSysParamUpdateKeyPrefix() []byte {
	return []byte(GenSysContractName(ContractEventSysParamUpdate))
}

// GeneConsensusUpdateKeyPrefix generate consensus update prefix
func GeneConsensusUpdateKeyPrefix() []byte {
	return []byte(GenSysContractName(ContractEventConsensusUpdate))
}
